//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet
{
    class Scenario : IOfficeXmlSerializable
    {
        private string _user;
        private string _name;
        private bool _locked;
        private bool _hidden;
        private string _comment;
        List<InputCells> inputCells = new List<InputCells>();

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("scenario"))
            {
                _name = c.GetOptionalString("name");
                _locked = c.GetOptionalBoolean("locked", false);
                _hidden = c.GetOptionalBoolean("hidden",false);
                int? count = c.GetOptionalInteger("count");
                _user = c.GetOptionalString("user");
                _comment = c.GetOptionalString("comment");
                inputCells.Clear();
                inputCells.AddRange(c.ReadOptionalWhile<InputCells>("inputCells"));
            }

        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("scenario"))
            {
                c.SetOptionalString("name", _name);
                c.SetOptionalBoolean("locked", _locked, false);
                c.SetOptionalBoolean("hidden", _hidden, false);
                //int? count = c.SetOptionalInteger("count");
                c.SetOptionalString("user", _user);
                c.SetOptionalString("comment", _comment);
                c.WriteElements(inputCells);
            }

        }
    }
}
